package com.bwie.parkdemo.mvvm.model.entity;

import com.bwie.lib_core.base.BaseEntity;
import com.google.gson.Gson;

import org.json.JSONArray;
import org.json.JSONException;

import java.util.ArrayList;
import java.util.List;

/**
 * 维修实体类
 * {
 "msg": "请求成功",
 "values": "[{\"departmentId\":1,
 \"repairData\":\"string\",
 \"repairDescribe\":\"string\",
 \"repairId\":47,
 \"repairTime\":\"string\",
 \"repairUserId\":50,\"userId\":48},{\"departmentId\":0,\"repairData\":\"2020-03-05\",\"repairDescribe\":\"水管漏水\",\"repairId\":48,\"repairTime\":\"2020-03-05\",\"repairUserId\":0,\"userId\":0},{\"departmentId\":0,\"repairData\":\"2020-03-05\",\"repairDescribe\":\"水管漏水\",\"repairId\":49,\"repairTime\":\"2020-03-05\",\"repairUserId\":0,\"userId\":0},{\"departmentId\":0,\"repairData\":\"2020-03-05\",\"repairDescribe\":\"水管漏水\",\"repairId\":50,\"repairTime\":\"2020-03-05\",\"repairUserId\":0,\"userId\":0},{\"departmentId\":0,\"repairData\":\"2020-03-05\",\"repairDescribe\":\"水管漏水\",\"repairId\":51,\"repairTime\":\"2020-03-05\",\"repairUserId\":0,\"userId\":0},{\"departmentId\":0,\"repairData\":\"string\",\"repairDescribe\":\"string\",\"repairId\":52,\"repairTime\":\"string\",\"repairUserId\":0,\"userId\":0},{\"departmentId\":0,\"repairData\":\"string\",\"repairDescribe\":\"string\",\"repairId\":53,\"repairTime\":\"string\",\"repairUserId\":0,\"userId\":0},{\"departmentId\":1,\"repairId\":54,\"repairUserId\":0,\"userId\":1},{\"departmentId\":1,\"repairData\":\"1583405227\",\"repairDescribe\":\"123\",\"repairId\":55,\"repairTime\":\"1578221229\",\"repairUserId\":0,\"userId\":1}]",
 "statuesCode": "200"
 }
 * */
public class RepairEntity extends BaseEntity{

    public String values;
    private List<Object>datas;

    public List<Object> getDatas() {
        datas = new ArrayList<>();
        try {
            JSONArray jay = new JSONArray(values);
            for (int i = 0;i < jay.length();i ++){
                String str = jay.getJSONObject(i).toString();
                Values value = new Gson().fromJson(str,Values.class);
                datas.add(value);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return datas;
    }

    public static class Values{
        public int departmentId;
        public int repairId;
        public String repairData;
        public String repairDescribe;
        public String repairTime;
        public int repairUserId;
        public int userId;
        public boolean isShow = false;//是否显示选择框
        public boolean isSelect = false;//用户是否选中
    }

}
